package com.ericsson.web;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.ericsson.web.core.Constants;
import com.ericsson.web.core.HSQLDatabase;
import com.ericsson.web.core.IDatabase;

public class ChangeDescription extends HttpServlet {

	@Override
	protected void doPost(HttpServletRequest request, 
			HttpServletResponse response) 
	throws ServletException, IOException {
		doGet(request, response);
	}
	
	@Override
	protected void doGet(HttpServletRequest request, 
			HttpServletResponse response) 
	throws ServletException, IOException {
		String description = request.getParameter("description");
		IDatabase db = HSQLDatabase.getInstance();
		db.changeDescription(
				(Integer)request.getSession().getAttribute(Constants.USERID), 
				description);
		response.sendRedirect(Constants.INDEX_PAGE);
	}
}
